import java.util.*;

public class Leetcode {
    //只出现一次的数字
    public int singleNumber(int[] nums) {
        HashSet<Integer> set = new HashSet<>();
        for (int i = 0; i < nums.length; i++) {
            if(!set.contains(nums[i])){
                set.add(nums[i]);
            }else{
                set.remove(nums[i]);
            }
        }
        for (int i = 0; i < nums.length; i++) {
            if(set.contains(nums[i])){
                return nums[i];
            }
        }
        return -1;
    }

    //宝石与石头
    public int numJewelsInStones(String jewels, String stones) {
        HashSet<Character> set = new HashSet<>();
        int count = 0;
        for (int i = 0; i < jewels.length(); i++) {
            set.add(jewels.charAt(i));
        }
        for (int i = 0; i < stones.length(); i++) {
            if(set.contains(stones.charAt(i)))
            count++;
        }
        return count;
    }

    //坏键盘
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        while (in.hasNextLine()) { // 注意 while 处理多个 case
            String str1 = in.nextLine();
            String str2 = in.nextLine();
            func(str1,str2);
        }
    }

    public static void func(String str1,String str2){
        HashSet<Character> set = new HashSet<>();
        HashSet<Character> setBroken = new HashSet<>();

        for (char ch:str2.toUpperCase().toCharArray()) {
            set.add(ch);
        }
        for (char ch:str1.toUpperCase().toCharArray()) {
            if(!set.contains(ch) && !setBroken.contains(ch)){
                System.out.print(ch);
                setBroken.add(ch);
            }
        }
        System.out.println();
    }

    // 前K个高频单词
    public List<String> topKFrequent(String[] words, int k) {
        //1. 统计每个单词出现的次数
        Map<String,Integer> map = new HashMap<>();
        for (String word : words) {
            if(map.get(word) == null){
                map.put(word,1);
            }else{
                int val = map.get(word);
                map.put(word,val+1);
            }
        }
        //2. 创建小根堆
        PriorityQueue<Map.Entry<String,Integer>> minHeap = new PriorityQueue<>(new Comparator<Map.Entry<String, Integer>>() {
            @Override
            public int compare(Map.Entry<String, Integer> o1, Map.Entry<String, Integer> o2) {
                if(o1.getValue().compareTo(o2.getValue()) == 0){
                    return o2.getKey().compareTo(o1.getKey());
                }
                return o1.getValue().compareTo(o2.getValue());
            }
        });
        //3. 将统计结果放入小根堆
        for(Map.Entry<String,Integer> entry : map.entrySet()){
            if(minHeap.size() < k){
                minHeap.offer(entry);
            }else{
                Map.Entry<String,Integer> top = minHeap.peek();
                if(top.getValue().compareTo(entry.getValue()) == 0){
                    if(top.getKey().compareTo(entry.getKey()) > 0){
                        minHeap.poll();
                        minHeap.offer(entry);
                    }
                }else{
                    if(entry.getValue().compareTo(top.getValue()) > 0){
                        minHeap.poll();
                        minHeap.offer(entry);
                    }
                }
            }
        }
        //4. 获取前 k 个高频单词
        List<String> ret = new ArrayList<>();
        for (int i = 0; i < k; i++) {
            Map.Entry<String,Integer> tmp = minHeap.poll();
            ret.add(tmp.getKey());
        }
        Collections.reverse(ret);
        return ret;
    }

    //存在重复元素 II
    public boolean containsNearbyDuplicate(int[] nums, int k) {
            HashMap<Integer, Integer> set = new HashMap<>();
            for (int i = 0; i < nums.length; i++) {
                if (set.containsKey(nums[i])) {
                    int Index = set.get(nums[i]);
                    if (Math.abs(i - Index) <= k) {
                        return true;
                    }
                }
                set.put(nums[i], i);
            }
            return false;
    }

    //存在重复元素 I
    public boolean containsDuplicate(int[] nums) {
        HashMap<Integer, Integer> set = new HashMap<>();
        for (int i = 0; i < nums.length; i++) {
            if (set.containsKey(nums[i])) {
                return true;
            }
            set.put(nums[i], i);
        }
            return false;
    }

    //复杂链表的复制
//    public Node copyRandomList(Node head) {
//        HashMap<Node,Node> map = new HashMap<>();
//        //1. 第一次遍历链表
//        Node cur = head;
//        while(cur != null) {
//            Node node = new Node(cur.val);
//            map.put(cur,node);
//            cur = cur.next;
//        }
//
//        //2. 再次遍历链表
//        cur = head;
//        while(cur != null) {
//            map.get(cur).next = map.get(cur.next);
//            map.get(cur).random = map.get(cur.random);
//            cur = cur.next;
//        }
//        return map.get(head);
//    }

}
